package com.example.wacoffee_manage.Mapper;

import com.example.wacoffee_manage.DTO.getLastDTO;
import com.example.wacoffee_manage.pojo.TopProduct;
import com.example.wacoffee_manage.pojo.dayData;
import com.example.wacoffee_manage.pojo.exportData;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface reportMapper {

    Integer getLast7DaysOrdersCounts(LocalDate date);

    exportData getExportTotalData(LocalDate begin, LocalDate end);

    dayData getExportDayData(LocalDate localDate);

    List<TopProduct> getTopProducts(getLastDTO getLastDTO);

    Double getLast7DaysOrdersAmount(LocalDate date);

    Integer getLast7DaysOrdersUser(LocalDate date);

    Integer getLastDaysOrdersCounts(LocalDate date);

    Integer getLastDaysOrdersAmount(LocalDate date);

    @Select("select count(id) as counts from user where ((level > #{min} AND level <= #{max})) and create_time BETWEEN #{dto.startDate} AND #{dto.endDate} " )
    int getLastUserCounts(
            @Param("min") int min,
            @Param("max") int max,
            @Param("dto") getLastDTO getLastDTO);
    @Select("select count(id) as counts from user where date(create_time)=#{date}")
    Integer getNewUsersCounts(LocalDate date);
}
